package com.company.cloud.oss.modules.cloud;

import com.company.cloud.common.exception.BusinessException;
import com.company.cloud.oss.config.OssConfig;
import com.company.cloud.oss.constant.OssErrorEnum;
import com.company.cloud.oss.constant.OssTypeEnum;

public class OSSFactory {

	public static CloudStorageService build(OssConfig ossConfig) {
		if (OssTypeEnum.OSS_ALIYUN.getCode().equals(ossConfig.getOssType())) {
			return new AliyunCloudStorageService(ossConfig);
		} else if (OssTypeEnum.OSS_QCLOUD.getCode().equals(ossConfig.getOssType())) {
			return new QcloudCloudStorageService(ossConfig);
		} else if (OssTypeEnum.OSS_FILE.getCode().equals(ossConfig.getOssType())) {
			return new FileCloudStorageService(ossConfig);
		} else if (OssTypeEnum.OSS_QINIU.getCode().equals(ossConfig.getOssType())) {
			return new QiniuCloudStorageService(ossConfig);
		}else {
			throw new BusinessException(OssErrorEnum.OssCloud_Not);
		}
	}

}
